home *** CD-ROM | disk | FTP | other *** search
/ Sports Illustrated for Kids - Awesome Athletes! / Sports Illustrated for Kids - Awesome Athletes!.iso / tr.dir / 00006_EndGame.ls < prev    next >
Encoding:
Text File  |  1996-04-18  |  7.2 KB  |  248 lines

  1. on EndGame
  2.   global gcTRBAL_CH1, gcTRPLYR1SCORECH, gcTRPLYR2SCORECH, gzTRPlayerObj, gTRGameObj, gcTRSCOREBRD_CH, gcTRROVER, gTREndGame, gTREndThisGame
  3.   set vP1High to 0
  4.   set vP2High to 0
  5.   set vP1BeatHigh to 0
  6.   set vP2BeatHigh to 0
  7.   if not gTREndGame then
  8.     KillAllBalloons()
  9.   end if
  10.   set the trails of sprite gcTRROVER to 0
  11.   set the visible of sprite gcTRROVER to 1
  12.   set the locH of sprite gcTRROVER to 318
  13.   set the locV of sprite gcTRROVER to 208
  14.   GetPlayersNames()
  15.   set vTheWinner to GetWinner()
  16.   set vPlayerOne to mGetMyName(getAt(gzTRPlayerObj, 1))
  17.   set vP1Score to mGetMyCurrentScore(getAt(gzTRPlayerObj, 1))
  18.   set vP1High to mGetMyHighestScore(getAt(gzTRPlayerObj, 1))
  19.   if vP1Score > vP1High then
  20.     mSetMyHighestScore(getAt(gzTRPlayerObj, 1), vP1Score)
  21.     set vP1BeatHigh to 1
  22.   end if
  23.   set vPlayMode to mGetPlayMode(gTRGameObj)
  24.   if vPlayMode = 1 then
  25.     if not gTREndGame then
  26.       GetPlayersNames()
  27.       StartNewGame()
  28.       return 
  29.     else
  30.       if vP1BeatHigh then
  31.         ShowLoginScreens(vP1BeatHigh, 0, 1)
  32.       else
  33.         go("StopGame")
  34.       end if
  35.     end if
  36.   end if
  37.   if vPlayMode = 2 then
  38.     set vP2Score to mGetMyCurrentScore(getAt(gzTRPlayerObj, 2))
  39.     set vP2High to mGetMyHighestScore(getAt(gzTRPlayerObj, 2))
  40.     if vP2Score > vP2High then
  41.       mSetMyHighestScore(getAt(gzTRPlayerObj, 2), vP2Score)
  42.       set vP2BeatHigh to 1
  43.     end if
  44.     ShowTheWinner(vTheWinner)
  45.     if gTREndThisGame then
  46.       ShowLoginScreens(vP1BeatHigh, vP2BeatHigh, vTheWinner)
  47.       set gTREndThisGame to 0
  48.     else
  49.       set the visible of sprite 45 to 0
  50.       updateStage()
  51.       if not gTREndGame then
  52.         GetPlayersNames()
  53.         StartNewGame()
  54.       end if
  55.       return 
  56.     end if
  57.   end if
  58. end
  59.  
  60. on ShowLoginScreens vP1BeatHigh, vP2BeatHigh, vTheWinner
  61.   global gTREndGame, gzTRPlayerObj
  62.   if vP1BeatHigh and vP2BeatHigh then
  63.     updateStage()
  64.     go("TwoHighScores")
  65.   else
  66.     if vP1BeatHigh and (vTheWinner = 1) then
  67.       updateStage()
  68.       go("P1HighScore")
  69.     else
  70.       if vP2BeatHigh and (vTheWinner = 2) then
  71.         updateStage()
  72.         go("P2HighScore")
  73.       end if
  74.     end if
  75.   end if
  76. end
  77.  
  78. on EnterNewChamps
  79.   global gSIUserName, gzTRPlayerObj, gzTRPersBestScores, gTRGameObj, gzTRAllTimeHighs
  80.   GetPlayersNames()
  81.   set vPlayerOne to mGetMyName(getAt(gzTRPlayerObj, 1))
  82.   set vPlayerTwo to mGetMyName(getAt(gzTRPlayerObj, 2))
  83.   set vP1BeatHigh to mGetBeatHighScore(getAt(gzTRPlayerObj, 1))
  84.   set vP2BeatHigh to mGetBeatHighScore(getAt(gzTRPlayerObj, 2))
  85.   set vP1Score to mGetMyCurrentScore(getAt(gzTRPlayerObj, 1))
  86.   set vP2Score to mGetMyCurrentScore(getAt(gzTRPlayerObj, 2))
  87.   addProp(gzTRAllTimeHighs, vPlayerOne, value(vP1Score))
  88.   if vP1BeatHigh and (vPlayerOne = gSIUserName) then
  89.     add(gzTRPersBestScores, vP1Score)
  90.   end if
  91.   set vPlayMode to mGetPlayMode(gTRGameObj)
  92.   addProp(gzTRAllTimeHighs, vPlayerTwo, value(vP2Score))
  93.   if vPlayMode = 2 then
  94.     if vP2BeatHigh and (vPlayerTwo = gSIUserName) then
  95.       add(gzTRPersBestScores, vP2Score)
  96.     end if
  97.   end if
  98.   MakeChampList()
  99.   MakePersBestList()
  100. end
  101.  
  102. on GetPlayersNames
  103.   global gzTRPlayerObj
  104.   set vPlayerOne to the text of field "P1LogIn"
  105.   set vPlayerTwo to the text of field "P2LogIn"
  106.   mSetMyName(getAt(gzTRPlayerObj, 1), vPlayerOne)
  107.   mSetMyName(getAt(gzTRPlayerObj, 2), vPlayerTwo)
  108. end
  109.  
  110. on MakeChampList
  111.   global gzTRAllTimeHighs
  112.   set vFinalListLeft to EMPTY
  113.   set vFinalListRight to EMPTY
  114.   set the text of cast "ChampionListATBleft" to " "
  115.   set the text of cast "ChampionListATBright" to " "
  116.   set vSortedList to [:]
  117.   set vSortedList to SortListDescending()
  118.   repeat with vI = 1 to count(vSortedList)
  119.     set vName to vI & ". " & getPropAt(vSortedList, vI)
  120.     set vScore to getAt(vSortedList, vI)
  121.     if vI < 6 then
  122.       set vFinalListLeft to vFinalListLeft & " " & vName & " " & vScore & RETURN
  123.       next repeat
  124.     end if
  125.     if vI > 5 then
  126.       set vFinalListRight to vFinalListRight & " " & vName & " " & vScore & RETURN
  127.     end if
  128.   end repeat
  129.   set the text of cast "ChampionListATBleft" to vFinalListLeft
  130.   set the text of cast "ChampionListATBright" to vFinalListRight
  131.   SetChampsAttribs()
  132. end
  133.  
  134. on SortListDescending
  135.   global gzTRAllTimeHighs
  136.   set vMaxChamps to 10
  137.   set vCount to 0
  138.   set vSortedList to [:]
  139.   set vTempList to [:]
  140.   set vTempList to value(string(gzTRAllTimeHighs))
  141.   repeat while (count(vTempList) > 0) and (vCount < vMaxChamps)
  142.     set vBig to max(vTempList)
  143.     set vName to getOne(vTempList, vBig)
  144.     set vPos to getPos(vTempList, vBig)
  145.     set vScore to vBig
  146.     addProp(vSortedList, vName, vScore)
  147.     deleteAt(vTempList, vPos)
  148.     set vCount to vCount + 1
  149.   end repeat
  150.   return vSortedList
  151. end
  152.  
  153. on MakePersBestList
  154.   global gSIUserName, gzTRPersBestScores, startMovie, gzTRPlayerObj
  155.   set vPlayerOne to mGetMyName(getAt(gzTRPlayerObj, 1))
  156.   set vPlayerTwo to mGetMyName(getAt(gzTRPlayerObj, 2))
  157.   if (gSIUserName <> vPlayerOne) and (gSIUserName <> vPlayerTwo) then
  158.     return 
  159.   end if
  160.   set vFinalListLeft to EMPTY
  161.   set vFinalListRight to EMPTY
  162.   set the text of cast "PersonalBestLeft" to " "
  163.   set the text of cast "PersonalBestright" to " "
  164.   SetChampsAttribs()
  165.   set vTemp to list()
  166.   set vTemp to value(string(gzTRPersBestScores))
  167.   sort(vTemp)
  168.   set gzTRPersBestScores to list()
  169.   set vCount to 1
  170.   repeat with vI = count(vTemp) down to 1
  171.     add(gzTRPersBestScores, getAt(vTemp, vI))
  172.     set vCount to vCount + 1
  173.     if vCount > 10 then
  174.       exit repeat
  175.     end if
  176.   end repeat
  177.   repeat with vI = 1 to count(gzTRPersBestScores)
  178.     set vName to vI & ". " & gSIUserName
  179.     set vScore to getAt(gzTRPersBestScores, vI)
  180.     if vI < 6 then
  181.       set vFinalListLeft to vFinalListLeft & " " & vName & " " & vScore & RETURN
  182.       next repeat
  183.     end if
  184.     if vI > 5 then
  185.       set vFinalListRight to vFinalListRight & " " & vName & " " & vScore & RETURN
  186.     end if
  187.   end repeat
  188.   set the text of cast "PersonalBestLeft" to vFinalListLeft
  189.   set the text of cast "PersonalBestRight" to vFinalListRight
  190.   SetChampsAttribs()
  191. end
  192.  
  193. on GetWinner
  194.   global gzTRPlayerObj, gTRGameObj
  195.   set vPlayMode to mGetPlayMode(gTRGameObj)
  196.   if vPlayMode = 1 then
  197.     return 1
  198.   end if
  199.   set p1Score to mGetMyCurrentScore(getAt(gzTRPlayerObj, 1))
  200.   set p2Score to mGetMyCurrentScore(getAt(gzTRPlayerObj, 2))
  201.   if p1Score > p2Score then
  202.     set vTheWinner to 1
  203.   end if
  204.   if p2Score > p1Score then
  205.     set vTheWinner to 2
  206.   end if
  207.   if p1Score = p2Score then
  208.     set vTheWinner to 0
  209.   end if
  210.   return vTheWinner
  211. end
  212.  
  213. on ShowTheWinner aTheWinner
  214.   global gcTRROVER, gTRWinnerFrameRelease
  215.   set gTRWinnerFrameRelease to 0
  216.   go("ShowWinner")
  217.   if aTheWinner = 1 then
  218.     set the castNum of sprite gcTRROVER to the number of cast "Player1Wins"
  219.     updateStage()
  220.     updateStage()
  221.     repeat while soundBusy(1)
  222.       nothing()
  223.     end repeat
  224.   else
  225.     if aTheWinner = 2 then
  226.       set the castNum of sprite gcTRROVER to the number of cast "Player2Wins"
  227.       updateStage()
  228.       updateStage()
  229.       repeat while soundBusy(1)
  230.         nothing()
  231.       end repeat
  232.     else
  233.       set the castNum of sprite gcTRROVER to the number of cast "TieGameWins"
  234.       updateStage()
  235.       updateStage()
  236.       repeat while soundBusy(1)
  237.         nothing()
  238.       end repeat
  239.     end if
  240.   end if
  241.   myDelay(120)
  242.   set gTRWinnerFrameRelease to 1
  243.   set the visible of sprite gcTRROVER to 0
  244.   set the locH of sprite gcTRROVER to -10
  245.   set the locV of sprite gcTRROVER to -10
  246.   updateStage()
  247. end
  248.